package BanyuanClub.Study.Day0310.网络编程;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) {
        try {
            //自动进行链接
            Socket socket = new Socket("localhost" , 8888);
            BufferedReader bis = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            Scanner in = new Scanner(System.in);
            PrintWriter pw = new PrintWriter(socket.getOutputStream(),true);

            new Thread(()-> {
                while (true){
                    //all#开头发给所有，1#发给1号
                    pw.println(in.next());
                }
            }).start();

            while (true) {
                String s = bis.readLine();
                System.out.println(s);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
